package view.subscriberpanels;

import javax.swing.JComponent;

import prefuse.Visualization;
import view.ViewManager;
import view.visualizations.DateZoomVis;
import view.visualizations.MeetZoomVis;
import view.visualizations.XCLineVis;

public abstract class VisSubscriber extends JComponent {
	
	public VisSubscriber() {
//		visChanged(ViewManager.getCurrentVis());
		ViewManager.subscribe(this);
	}
	
	/**
	 * Called by the VisManager whenever the overall vis layer changes.
	 * @param vis the new visualization.
	 */
	public void visChanged(final Visualization vis) {
		if (vis instanceof XCLineVis) {
			showOverallView();
		} else if (vis instanceof DateZoomVis) {
			showDateZoomView();
		} else if (vis instanceof MeetZoomVis) {
			showMeetZoomView();
		} else {
			showTableView();
		}
		this.repaint();
		this.paintAll(this.getGraphics());
	}
	
	public void tableChanged() {
		updateView();
		this.repaint();
		this.paintAll(this.getGraphics());
	}
	
	abstract void updateView();
	
	abstract void showOverallView();
	abstract void showDateZoomView();
	abstract void showMeetZoomView();
	abstract void showTableView();
}
